package com.coollang.smartbra.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.amap.api.maps.model.LatLng;
import com.coollang.smartbra.R;
import com.coollang.smartbra.activity.AboutTeamActivity;
import com.coollang.smartbra.activity.ActionActivity;
import com.coollang.smartbra.activity.ActionDetailActivity;
import com.coollang.smartbra.activity.ActionDetailsActivity;
import com.coollang.smartbra.activity.CountActionDetailsActivity;
import com.coollang.smartbra.activity.CountTimeActivity;
import com.coollang.smartbra.activity.DeviceInfoActivity;
import com.coollang.smartbra.activity.DeviceUpdateActivity;
import com.coollang.smartbra.activity.DifficultyActivity;
import com.coollang.smartbra.activity.EditNameActivity;
import com.coollang.smartbra.activity.FinishActivity;
import com.coollang.smartbra.activity.LoginActivity;
import com.coollang.smartbra.activity.MainActivity;
import com.coollang.smartbra.activity.NewActionActivity;
import com.coollang.smartbra.activity.NewCountActionDetailsActivity;
import com.coollang.smartbra.activity.NewShareActivity;
import com.coollang.smartbra.activity.NewSportPlanActivity;
import com.coollang.smartbra.activity.NewTimeActionDetailsActivity;
import com.coollang.smartbra.activity.RedEnvelopesActivity;
import com.coollang.smartbra.activity.RunningActivity;
import com.coollang.smartbra.activity.SearchActivity;
import com.coollang.smartbra.activity.SelfInfoActivity;
import com.coollang.smartbra.activity.SetHeartRateActivity;
import com.coollang.smartbra.activity.ShareActivity;
import com.coollang.smartbra.activity.ShareMapActivity;
import com.coollang.smartbra.activity.SportAnalyzeActivity;
import com.coollang.smartbra.activity.SportStatisticsActivity;
import com.coollang.smartbra.activity.SportStatisticsActivity1;
import com.coollang.smartbra.activity.StrengthActivity;
import com.coollang.smartbra.activity.SystemSettingActivity;
import com.coollang.smartbra.activity.UMoneyDetailsActivity;
import com.coollang.smartbra.activity.ViconDataActivity;
import com.coollang.smartbra.activity.WebViewActivity;
import com.coollang.smartbra.activity.Welcome2Activity;
import com.coollang.smartbra.beans.ActionData;
import com.coollang.smartbra.beans.NewActionData;
import com.coollang.smartbra.constant.Constants;

import java.util.ArrayList;


/**
 * 页面跳转
 */
public class ActivitySwitcher {

    private static void startActivityFromRight(Activity activity, Intent intent) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_right);
    }

    private static void startActivityFromBottom(Activity activity, Intent intent) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.push_down_in, R.anim.activity_stay);
    }

    private static void startActivityAlpha(Activity activity, Intent intent) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    }

    private static void startActivityScale(Activity activity, Intent intent) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.scale_in, R.anim.scale_out);
    }

    private static void startActivityScaleTwo(Activity activity, Intent intent) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.scale_alpha_in, R.anim.scale_alpha_out);
    }

    private static void startActivityDefault(Activity activity, Intent intent) {
        activity.startActivity(intent);
    }

    /**
     * 设备搜索页面
     */
    public static void goSearchAct(Activity activity) {
        Intent intent = new Intent(activity, SearchActivity.class);
        startActivityFromBottom(activity, intent);
    }

    public static void goSetHeartRateAct(Activity activity) {
        Intent intent = new Intent(activity, SetHeartRateActivity.class);
        startActivityDefault(activity, intent);
    }

    public static void goDeviceUpdateAct(Activity activity) {
        Intent intent = new Intent(activity, DeviceUpdateActivity.class);
        startActivityDefault(activity, intent);
    }

    public static void goMapAct1(Activity activity) {
        Intent intent = new Intent(activity, RunningActivity.class);
        startActivityDefault(activity, intent);
    }

    public static void goShareMapAct(Activity activity, String uuid, boolean upLoad, long length) {
        Intent intent = new Intent(activity, ShareMapActivity.class);
        // intent.putExtra("uuid", uuid);
        // intent.putExtra("upLoad", upLoad);
        // intent.putExtra("length", length);
        startActivityDefault(activity, intent);
    }

    public static void goShareMapAct(Activity activity, ArrayList<LatLng> list) {
        Intent intent = new Intent(activity, ShareMapActivity.class);
        intent.putParcelableArrayListExtra("latlnglist", list);
        startActivityDefault(activity, intent);
    }

    public static void goShareAct(Activity activity, int type) {
        Intent intent = new Intent(activity, ShareActivity.class);
        intent.putExtra("type", type);
        activity.startActivityForResult(intent, 821);
        activity.overridePendingTransition(R.anim.scale_in, R.anim.scale_out);
    }

    /**
     * 完成目标值 奖励页面
     */
    public static void goFinishAct(Activity activity, int num, int type) {
        Intent intent = new Intent(activity, FinishActivity.class);
        intent.putExtra("num", num);
        intent.putExtra("type", type);
        startActivityScale(activity, intent);
    }

    /**
     * 跳转到登录页
     */
    public static void goMainActivity(Context mContext) {
        Intent intent = new Intent(mContext, MainActivity.class);
        mContext.startActivity(intent);
    }

    /**
     * 跳转到个人信息编辑页面
     */
    public static void goToSelfInfoEdit(Activity activity) {
        Intent intent = new Intent(activity, SelfInfoActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到运动统计
     */
    public static void goToSportStatistics(Activity activity, int index) {
        Intent intent = new Intent(activity, SportStatisticsActivity.class);
        intent.putExtra("index", index);
        startActivityDefault(activity, intent);
    }
    /**
     * 跳转到运动统计
     */
    public static void goToSportStatistics1(Activity activity, int index) {
        Intent intent = new Intent(activity, SportStatisticsActivity1.class);
        intent.putExtra("index", index);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到系统设置
     */
    public static void goToSystemSetting(Activity activity) {
        Intent intent = new Intent(activity, SystemSettingActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到运动计划
     */
    public static void goToSportPlan(Activity activity) {
        Intent intent = new Intent(activity, NewSportPlanActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到综合分析
     */
    public static void goToSportAnalyze(Activity activity) {
        Intent intent = new Intent(activity, SportAnalyzeActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到欢迎  计划修改页面
     */
    public static void goToWelcomeAct(Activity activity, String from) {
        Intent intent = new Intent(activity, Welcome2Activity.class);
        //intent.putExtra(Constants.WELCOME_FROM, from);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到动作库页面
     */
    public static void goViconDataAct(Activity activity) {
        Intent intent = new Intent(activity, ViconDataActivity.class);
        startActivityDefault(activity, intent);
    }

    // 跳转到登录页面
    public static void goLoginAct(Activity activity) {
        Intent intent = new Intent(activity, LoginActivity.class);
        startActivityDefault(activity, intent);
    }

    // 跳转到红包页面
    public static void goReEenvelopesAct(Activity activity) {
        Intent intent = new Intent(activity, RedEnvelopesActivity.class);
        startActivityDefault(activity, intent);
    }

    public static void goEditNameAct(Activity activity, String text, boolean editDeviceName) {
        Intent intent = new Intent(activity, EditNameActivity.class);
        intent.putExtra(Constants.EDITNMAE_TEXT, text);
        intent.putExtra("editDeviceName", editDeviceName);
        startActivityDefault(activity, intent);
    }

    /**
     * 3 2 1 倒计时页面
     */
    public static void goCountTimeAct(Activity activity, View view) {
        Intent intent = new Intent(activity, CountTimeActivity.class);
        if (PackageUtils.getSDKInt() >= 21) {
            CircularAnimUtil.startActivity(activity, intent, view, R.color.progrss_bg);
        } else {
            startActivityDefault(activity, intent);
        }
    }

    /**
     * 跳转到跳转到设备信息页面
     */
    public static void goToDeviceInfo(Activity activity) {
        Intent intent = new Intent(activity, DeviceInfoActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到具体动作页面
     */
    public static void goToAction(Activity activity, int type) {
        Intent intent = new Intent(activity, ActionActivity.class);
        intent.putExtra("type", type);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到最新的动作页面
     */
    public static void goToNewAction(Activity activity, int type) {
        Intent intent = new Intent(activity, NewActionActivity.class);
        intent.putExtra(Constants.TYPE, type);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到具体动作详情页面显示动作时间,动作个数
     */
    public static void goToActionDetails(Activity activity, ArrayList<Integer> list, ArrayList<ActionData> actionData) {
        Intent intent = new Intent(activity, ActionDetailsActivity.class);
        intent.putIntegerArrayListExtra("list", list);
        intent.putParcelableArrayListExtra("actionlist", actionData);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到具体个数页面
     */
    public static void gotoCountActionDetails(Activity activity, ArrayList<ActionData> list) {
        Intent intent = new Intent(activity, CountActionDetailsActivity.class);
        intent.putParcelableArrayListExtra("list", list);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转欢迎页面
     */
    public static void goToWelcome2(Activity activity) {
        Intent intent = new Intent(activity, Welcome2Activity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转设置训练难度等级页面
     */
    public static void goToDifficulty(Activity activity) {
        Intent intent = new Intent(activity, DifficultyActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转设置训练强度等级页面
     */
    public static void goToStrength(Activity activity) {
        Intent intent = new Intent(activity, StrengthActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转关于我们页面
     */
    public static void goToAboutTeamActivity(Activity activity) {
        Intent intent = new Intent(activity, AboutTeamActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转 WebView 页面
     */
    public static void goToWebViewActivity(Activity activity, int type) {
        Intent intent = new Intent(activity, WebViewActivity.class);
        intent.putExtra("web_type", type);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转 U币 明细页面
     */
    public static void goToUMoneyDetailsActivity(Activity activity) {
        Intent intent = new Intent(activity, UMoneyDetailsActivity.class);
        startActivityDefault(activity, intent);
    }

    /**
     * 动作库详情页面
     */
    public static void gotoActionDetail(Activity activity, int position) {
        Intent intent = new Intent(activity, ActionDetailActivity.class);
        intent.putExtra("position", position);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.open_enter, R.anim.open_exit);
    }

    /**
     * 跳转到新版具体个数页面
     */
    public static void gotoNewCountActionDetails(Activity activity, ArrayList<NewActionData> list) {
        Intent intent = new Intent(activity, NewCountActionDetailsActivity.class);
        intent.putParcelableArrayListExtra(Constants.LIST, list);
        startActivityDefault(activity, intent);
    }

    /**
     * 跳转到新版具体时间页面
     */
    public static void gotoNewTimeActionDetails(Activity activity, ArrayList<NewActionData> list) {
        Intent intent = new Intent(activity, NewTimeActionDetailsActivity.class);
        intent.putParcelableArrayListExtra(Constants.LIST, list);
        activity.startActivityForResult(intent, 821);
    }

    /**
     * 跳转到动作完成新版分享页面
     */
    public static void gotoNewShareActivity(Activity activity, ArrayList<NewActionData> list) {
        Intent intent = new Intent(activity, NewShareActivity.class);
        intent.putParcelableArrayListExtra(Constants.LIST, list);
        activity.startActivityForResult(intent, 820);
        activity.overridePendingTransition(R.anim.scale_in, R.anim.scale_out);
    }
}
